import matplotlib.pyplot as plt
import numpy as np

x = np.array(["bar1", "bar2", "bar3", "bar4"])
y = np.array([12, 22, 6, 18])

# 获取当前所操作的子图，使其更加对象化
ax = plt.gca()

ax.set_title("bar_test")
# ax.set_xlabel("x_axis")
# ax.set_ylabel("y_axis")
plt.bar(x,y,color="blue",width=0.5)
plt.show()